/*
 * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
 * http://www.gnu.org/licenses/lgpl-3.0.html
 *
 * $Revision: 8948 $
 * $Id: blockallocated.cpp 8948 2013-04-06 17:15:49Z alpha0010 $
 * $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-17.xx/src/sdk/blockallocated.cpp $
 */

#include "sdk_precomp.h"

#ifndef CB_PRECOMP
    #include <wx/log.h> // for wxSafeShowMessage()
    #include <wx/regex.h>
#endif
#include "blockallocated.h"

namespace BlkAllc
{

    void DebugLog(wxString cn, int blockSize, int poolSize, int max_refs, int total_refs, int ref_count)
    {
        wxString s;
        wxString cn2;

        if(total_refs == 0)
            return; // pointless

        wxRegEx r(_T("^[A-Z]?[0-9]+(.*)"));
        if(r.Matches(cn))
            cn2 = r.GetMatch(cn, 1);

        s.Printf(wxT("%s\n\n%d个大小为%d的保留池(总共%d个对象)\n"
        "最大分配对象数: %d\n"
        "分配总数: %d\n"
        "过时对象数: %d %s"),
        cn2.wx_str(),
        blockSize, poolSize, blockSize * poolSize,
        max_refs, total_refs, ref_count, (ref_count == 0 ? wxT("(无)"): wxT("(内存泄漏)")));

        wxSafeShowMessage(wxT("块分配器"), s);
    } // end of DebugLog
}
